﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class ybqy_print_1_10 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //先判断是否有数据，如无数据增加3条数据
        SqlConnection sqlcon = new SqlConnection();
        sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon.Open();
        SqlConnection sqlcon1 = new SqlConnection();
        sqlcon1.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon1.Open();

        SqlCommand sqlcmd = new SqlCommand("select * from a01110 where ShenBaoNianDu='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"] + " order by PROJECT_ID", sqlcon);

        SqlDataReader reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);



        if (!IsPostBack)
        {
            int sfys = 0;
            int i = 1;
            while (reader.Read())//有数据，将数据显示
            {
                sfys = 1;

                if (i == 1)
                {
                    PROJECT_NAME1.Text = reader["PROJECT_NAME"].ToString();
                    BEGIN_DATE1.Text = reader["BEGIN_DATE"].ToString();
                    USE_DATE1.Text = reader["USE_DATE"].ToString();
                    PLAN_MONEY1.Text = reader["PLAN_MONEY"].ToString();
                    SUM_YEARMONEY1.Text = reader["SUM_YEARMONEY"].ToString();
                    ALL_MONEY1.Text = reader["ALL_MONEY"].ToString();
                    YUS_MONEY1.Text = reader["YUS_MONEY"].ToString();
                    ENV_MONEY1.Text = reader["ENV_MONEY"].ToString();
                    OTHER_SUMMONEY1.Text = reader["OTHER_SUMMONEY"].ToString();
                    LEND_MONEY1.Text = reader["LEND_MONEY"].ToString();
                    FOREIN_MONEY1.Text = reader["FOREIN_MONEY"].ToString();
                    SELF_MONEY1.Text = reader["SELF_MONEY"].ToString();
                    DESIGN_ABILITY1.Text = reader["DESIGN_ABILITY"].ToString();
                    if (reader["MANAGE_TYPE"].ToString() != null && reader["MANAGE_TYPE"].ToString() != "" && reader["PROJECT_NAME"].ToString()!= null && reader["PROJECT_NAME"].ToString()!= "")
                    {
                        SqlCommand sqlcmd1 = new SqlCommand("select * from a01110_f where code=" + reader["MANAGE_TYPE"].ToString(), sqlcon1);

                        SqlDataReader reader1 = sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
                        if (reader1.Read())
                        {
                           MANAGE_TYPE1.Text = reader1["name"].ToString(); 
                        }
                        reader1.Close();
                        
                    }

                }

                if (i == 2)
                {
                    PROJECT_NAME2.Text = reader["PROJECT_NAME"].ToString();
                    BEGIN_DATE2.Text = reader["BEGIN_DATE"].ToString();
                    USE_DATE2.Text = reader["USE_DATE"].ToString();
                    PLAN_MONEY2.Text = reader["PLAN_MONEY"].ToString();
                    SUM_YEARMONEY2.Text = reader["SUM_YEARMONEY"].ToString();
                    ALL_MONEY2.Text = reader["ALL_MONEY"].ToString();
                    YUS_MONEY2.Text = reader["YUS_MONEY"].ToString();
                    ENV_MONEY2.Text = reader["ENV_MONEY"].ToString();
                    OTHER_SUMMONEY2.Text = reader["OTHER_SUMMONEY"].ToString();
                    LEND_MONEY2.Text = reader["LEND_MONEY"].ToString();
                    FOREIN_MONEY2.Text = reader["FOREIN_MONEY"].ToString();
                    SELF_MONEY2.Text = reader["SELF_MONEY"].ToString();
                    DESIGN_ABILITY2.Text = reader["DESIGN_ABILITY"].ToString();
                    if (reader["MANAGE_TYPE"].ToString() != null && reader["MANAGE_TYPE"].ToString() != "" && reader["PROJECT_NAME"].ToString()!= null && reader["PROJECT_NAME"].ToString()!= "")
                    {
                        SqlCommand sqlcmd1 = new SqlCommand("select * from a01110_f where code=" + reader["MANAGE_TYPE"].ToString(), sqlcon1);
                        sqlcon1.Open();
                        SqlDataReader reader1 = sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
                        if (reader1.Read())
                        {
                            MANAGE_TYPE2.Text = reader1["name"].ToString();
                        }
                        reader1.Close();
                        
                    }

                }
                if (i == 3)
                {
                    PROJECT_NAME3.Text = reader["PROJECT_NAME"].ToString();
                    BEGIN_DATE3.Text = reader["BEGIN_DATE"].ToString();
                    USE_DATE3.Text = reader["USE_DATE"].ToString();
                    PLAN_MONEY3.Text = reader["PLAN_MONEY"].ToString();
                    SUM_YEARMONEY3.Text = reader["SUM_YEARMONEY"].ToString();
                    ALL_MONEY3.Text = reader["ALL_MONEY"].ToString();
                    YUS_MONEY3.Text = reader["YUS_MONEY"].ToString();
                    ENV_MONEY3.Text = reader["ENV_MONEY"].ToString();
                    OTHER_SUMMONEY3.Text = reader["OTHER_SUMMONEY"].ToString();
                    LEND_MONEY3.Text = reader["LEND_MONEY"].ToString();
                    FOREIN_MONEY3.Text = reader["FOREIN_MONEY"].ToString();
                    SELF_MONEY3.Text = reader["SELF_MONEY"].ToString();
                    DESIGN_ABILITY3.Text = reader["DESIGN_ABILITY"].ToString();
                    
                    if (reader["MANAGE_TYPE"].ToString() != null && reader["MANAGE_TYPE"].ToString() != "" && reader["PROJECT_NAME"].ToString()!= null && reader["PROJECT_NAME"].ToString()!= "")
                    {
                        SqlCommand sqlcmd1 = new SqlCommand("select * from a01110_f where code=" + reader["MANAGE_TYPE"].ToString(), sqlcon1);

                        sqlcon1.Open();
                        SqlDataReader reader1 = sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
                        if (reader1.Read())
                        {
                            MANAGE_TYPE3.Text = reader1["name"].ToString();
                        }
                        reader1.Close();
                        
                    }

                }
                i = i + 1;
            }
            sqlcon.Close();
                        
            sqlcon1.Close();
        }
    }
}